import { Component } from '@angular/core';
import {NavController, NavParams } from 'ionic-angular';

import 'rxjs/add/operator/toPromise';
import {HttpServies} from '../../providers/http-servies';


@Component({
  selector: 'page-yhxx',
  templateUrl: 'yhxx.html',
  providers:[HttpServies]
})
export class YhxxPage {
    dataJson:any=[];
  userInfo = {
    'name': '',
    'gender': '',
    'birthday': '',
    'education': '',
    'major': '',
    'worktime': '',
    'email': '',
    'card': '',
  }

    ionViewDidLoad() {
        this.getInfo();
    }

  constructor(public navCtrl: NavController, public navParams: NavParams, private http: HttpServies) {


  }

/*
* 用户信息修改方法
* */

  checkInfo() {
      var param = "name=" + this.dataJson.name
       +  "&gender=" + this.dataJson.gender
        + "&birthday=" + this.dataJson.birthday
        + "&education=" + this.dataJson.education
        + "&major=" + this.dataJson.major
        + "&worktime=" + this.dataJson.worktime
        + "&email=" + this.dataJson.email
        + "&card=" + this.dataJson.card;
    this.http.httpPost('/home/index/people', param)
        .then(res => {
          //成功
          if (res && res.code != 0) {
            this.http.showErro(res.msg);
            console.log(res.msg);
          }

        })
        .catch(error => {
          this.http.showErro("保存失败"+error);
        });
  }

    getInfo() {
        this.http.httpPost('/Home/index/query')
            .then(res => {//成功
                if (res && res.code ==1) {
                    console.log(res.msg);
                    this.dataJson = res.data;
                }else {
                    this.http.showErro(res.msg);
                }
            })





    }

}
